package model.member;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.Random;

public class MemberService {
	private MemberDao memberDao;
	public void setMemberDao(MemberDao memberDao){
		this.memberDao=memberDao;
	}
	public MemberVO login(MemberVO vo) throws SQLException {		
		return memberDao.login(vo);
	}
	public void update(MemberVO vo) throws SQLException{
		memberDao.update(vo);
	}
	public String idCheck(String id) throws SQLException {
		String mess;
		MemberVO vo=memberDao.idCheck(id);
		if(vo!=null){
			mess="생성할 수 없는 id입니다.";
		}else{
			mess="생성할 수 있는 id입니다.";
		}
		return mess;
	}
	
	public String nickCheck(String nick) throws SQLException {
		String mess;
		MemberVO vo=memberDao.nickCheck(nick);
		if(vo!=null){
			mess="생성할 수 없는 별명입니다.";
		}else{
			mess="생성할 수 있는 별명입니다.";
		}
		return mess;
	}
	public void registerMember(MemberVO vo) throws SQLException {
		memberDao.registerMember(vo);
	}
	
	public HashMap notDuplicate(String uri) throws SQLException{
		Random r=new Random();
		int j=r.nextInt(10);
		uri=j+".png";
		System.out.println(uri);
		return memberDao.notDuplicate(uri);
	}
	//회원수 조회
	public String countId() throws SQLException{
		return memberDao.countId();
	}
}
